package com.learn.smart.framework.util;

import java.net.URLDecoder;
import java.net.URLEncoder;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public final class CodecUtil {
	
	private static final Logger log = LoggerFactory.getLogger(CodecUtil.class);
	
	/**编码*/
	public static String encodeURL(String source){
		String target="";
		try {
			target = URLEncoder.encode(source,"UTF-8");
		} catch (Exception e) {
			log.error("编码失败",e);
			e.printStackTrace();
		}
		return target;
	}
	
	/**解码*/
	public static String decodeURL(String source){
		String target="";
		try {
			target = URLDecoder.decode(source,"UTF-8");
		} catch (Exception e) {
			log.error("解码失败",e);
			e.printStackTrace();
		}
		return target;
	}

}
